Fix a typo in 'window_text_pixel_size'
authorEli Zaretskii <eliz@gnu.org>
Mon, 24 Feb 2025 19:02:14 +0000 (21:02 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 24 Feb 2025 19:02:14 +0000 (21:02 +0200)
This typo caused strange mis-behaviors in buffers
with non-ASCII characters.
* src/xdisp.c (window_text_pixel_size): Fix typo.  (Bug#76519)

src/xdisp.c

index f11a8aa6d55d60f4b936c888aeb33bedf2561bee..eb00c510aaac5497e608eede04c8b3da6df44b0d 100644 (file)
@@ -11546,6 +11546,7 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to,
   it.bidi_p = false;
 
   int start_x;
+  ptrdiff_t start_bpos = BYTEPOS (startp);
   if (vertical_offset != 0)
     {
       int last_y;
@@ -11578,6 +11579,7 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to,
       it.current_y = (WINDOW_TAB_LINE_HEIGHT (w)
                      + WINDOW_HEADER_LINE_HEIGHT (w));
       start = clip_to_bounds (BEGV, IT_CHARPOS (it), ZV);
+      start_bpos = CHAR_TO_BYTE (start);
       start_y = it.current_y;
       start_x = it.current_x;
     }
@@ -11639,7 +11641,7 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to,
   it.current_y = start_y;
   /* If FROM is on a newline, pretend that we start at the beginning
      of the next line, because the newline takes no place on display.  */
-  if (FETCH_BYTE (start) == '\n')
+  if (FETCH_BYTE (start_bpos) == '\n')
     it.current_x = 0, it.wrap_prefix_width = 0;
   if (!NILP (x_limit))
     {